package cn.wrl.user.service;

import cn.wrl.user.pojo.UserAddress;
import cn.wrl.user.pojo.bo.UserAddressBO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient("foodie-user-service")
@RequestMapping("address-api")
public interface AddressService {

    /**
     * 查询用户地址列表
     *
     * @param userId
     * @return
     */
    @GetMapping("addressList")
    List<UserAddress> queryAll(@RequestParam("userId") String userId);

    /**
     * 添加地址
     *
     * @param userAddressBO
     */
    @PostMapping("address")
    void addUserAddress(@RequestBody UserAddressBO userAddressBO);

    /**
     * 修改地址
     *
     * @param userAddressBO
     */
    @PutMapping("updateAddress")
    void updateUserAddress(@RequestBody UserAddressBO userAddressBO);

    /**
     * 删除地址
     *
     * @param userId
     * @param addressId
     */
    @DeleteMapping("deleteAddress")
    void deleteAddress(@RequestParam("userId") String userId,
                       @RequestParam("addressId") String addressId);

    /**
     * 修改默认地址
     *
     * @param userId
     * @param addressId
     */
    @PostMapping("setDefaultAddress")
    void setDefaultAddress(@RequestParam("userId") String userId,
                           @RequestParam("addressId") String addressId);


    @GetMapping("queryAddress")
    UserAddress queryUserAddress(@RequestParam("userId") String userId,
                                 @RequestParam(value = "addressId", required = false) String addressId);
}
